package com.example.backend.controller;

import com.example.backend.Requset.AddLogsRequest;
import com.example.backend.Requset.CreateRoomRequest;
import com.example.backend.pojo.Logs;
import com.example.backend.pojo.Room;
import com.example.backend.service.LogsService;
import com.example.backend.service.RoomService;
import com.example.backend.util.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/room")
public class RoomController {
    @Autowired
    private RoomService roomService;
    @Autowired
    private LogsService logsService;

    @GetMapping("/all")
    public Response<List<Room>> findAll() {
        return roomService.findAll();
    }
    @PostMapping("/new")
    public Response<Room> createRoom(@RequestBody CreateRoomRequest room) {
        return roomService.createRoom(room);
    }
    @PostMapping("/enter")
    public Response<Logs> addEnterLogs(@RequestBody AddLogsRequest logs){
        return logsService.addEnterLogs(logs);
    }
    @PostMapping("/exit")
    public Response<Logs> addExitLogs(@RequestBody AddLogsRequest logs){
        return logsService.addExitLogs(logs);
    }
}
